<?php
class magama extends CI_Model{
	var $agama = "m_agama";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_agama,$nama_agama)
	{
		$this->id_agama= $id_agama;
		$this->nama_agama= $nama_agama;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->agama, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->agama);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{		
		$arrayData = array(
			'id_agama'=>$this->id_agama,
			'nama_agama'=>$this->nama_agama
		);
		return $this->db->insert($this->agama, $arrayData);
	}
	
	function update($id_agama)
	{
		$arrayData = array(
			'nama_agama'=>$this->nama_agama
		);
		$this->db->where('id_agama', $id_agama);
		return $this->db->update($this->agama, $arrayData);
	}
        
	function remove($id_agama)
	{
		$this->db->where('id_agama', $id_agama);
		return $this->db->delete($this->agama);
	}	
	
	function detail($id_agama)
	{
		$this->db->where('id_agama', $id_agama);
		$query = $this->db->get($this->agama);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('nama_agama',$name);
		$query = $this->db->get($this->agama);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
}
?>